package com.infoclue.modules.quartz.job;

import com.infoclue.modules.km.service.IKmsDocService;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.DateUtils;

import com.infoclue.modules.km.utils.MinioService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;



/**
 * 读取minio 数据
 *
 * @Author zhutan
 */
@Slf4j
public class MinIOJob implements Job {

    /**
     * 若参数变量名修改 QuartzJobController中也需对应修改
     */
    private String parameter;
    @Autowired
    private IKmsDocService kmsDocService;

    @Autowired
    private MinioService minioService;

    public void setParameter(String parameter) {
        this.parameter = parameter;
    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        log.info("MinIOJob Parameters：" + this.parameter);
        String[] params = this.parameter.split("#");

        if (params.length > 3) {

            log.info("MinIOJob Execution key：" + jobExecutionContext.getJobDetail().getKey());

            this.kmsDocService.indexToKMS(params[0],params[1],params[2],params[3]);

        }
        log.info(String.format("welcome %s! MinIOJob带参数定时任务时间:" + DateUtils.now(), this.parameter));
    }
}
